#include "sys_config.h"

extern uint8_t keyflag;
#if 1
#define WENDU     0
#define SHIDU     1
#define GUANGZHAO 2
#define HONGWAI   3

uint8_t oledShowBuff[20] = {0};

/* 标题-温度 */
margin_t temp_title = {
    .top = 0,
    .left = 0,
};
/* 标题-湿度 */
margin_t humi_title = {
    .top = 0,
    .left = 0,
};
/* 数字-十位 */
margin_t number_1 = {
    .top = 16,
    .left = 8,
    .width = 16,
    .hight = 32
};
/* 数字-个位 */
margin_t number_2 = {
    .top = 16,
    .left = 24,
    .width = 16,
    .hight = 32
};
/* 小数点 */
margin_t dian = {
    .top = 32,
    .left = 40,
    .width = 16,
    .hight = 16
};

/* 小数点上空格 */
margin_t dian_kongge = {
    .top = 16,
    .left = 40,
    .width = 16,
    .hight = 16
};
/* 数字-小数 */
margin_t number_3 = {
    .top = 16,
    .left = 56,
    .width = 16,
    .hight = 32
};
/* 单位 */
margin_t danwei = {
    .top = 36,
    .left = 72,
    .width = 16,
    .hight = 16
};
/* 图片 */
margin_t image = {
    .top = 16,
    .left = 88,
    .width = 40,
    .hight = 40
};

/*显示灯、风扇、报警器状态 */
margin_t   png_left       = { .top = 16, .left = 5, };
margin_t   png_middle     = { .top = 16, .left = 45, }; 
margin_t   png_right      = { .top = 16, .left = 85, };

margin_t   text_left      = { .top = 3, .left = 8, };
margin_t   text_middle    = { .top = 3, .left = 48, };
margin_t   text_right     = { .top = 3, .left = 88, };

unsigned char bmp_kongge[16] = {
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF 
};

unsigned char bmp_kongge2[32] = {
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};

/*生成文字 温 16*16*/
unsigned char bmp_wen[32] = 
{
   0xEF,0x9F,0xFD,0x73,0xFF,0xFF,0x01,0x6D,0x6D,0x6D,0x6D,0x6D,0x01,0xFF,0xFF,0xFF,
   0xFB,0xFB,0x81,0xFE,0xBF,0x81,0xBD,0xBD,0x81,0xBD,0x81,0xBD,0xBD,0x81,0xBF,0xFF 

};

/*生成文字 度 16*16*/
unsigned char bmp_du[32] = 
{
   0xFF,0xFF,0x03,0xDB,0xDB,0xDB,0x03,0xDA,0xD9,0xDB,0x03,0xDB,0xDB,0xDB,0xFB,0xFF,
   0xBF,0xCF,0x70,0x7F,0x7B,0xB3,0xAA,0xDA,0xDA,0xDA,0xAA,0xB3,0x7F,0x7F,0x7F,0xFF
   
};

/*生成文字 湿 16*16*/
unsigned char bmp_shi[32] = 
{
   0xEF,0x9F,0xFD,0x73,0xFF,0x01,0x6D,0x6D,0x6D,0x6D,0x6D,0x6D,0x01,0xFF,0xFF,0xFF,
   0xFB,0xFB,0x81,0xFE,0xBB,0xB7,0xAF,0x80,0xBF,0xBF,0x80,0xAF,0xB7,0xBB,0xBF,0xFF 
};

unsigned char bmp_guang[32] = {
    0xBF,0xBF,0xBD,0xBB,0xA7,0x3F,0xBF,0x80,0xBF,0x3F,0xAF,0xB7,0xB9,0xBF,0xBF,0xFF,
    0x7F,0x7F,0xBF,0xDF,0xE7,0xF8,0xFF,0xFF,0xFF,0xC0,0xBF,0xBF,0xBF,0xBF,0x87,0xFF
};/*"光",0*/
/* (16 X 16 , 宋体 )*/

unsigned char bmp_zhao[32] = {
    0xFF,0x01,0xBD,0xBD,0xBD,0x01,0xFF,0xBD,0x5D,0x61,0x7D,0x5D,0x3D,0x41,0xFF,0xFF,
    0x7F,0x90,0xF7,0xF7,0xD7,0x30,0xFF,0xFF,0xD0,0x37,0xF7,0xF7,0xD7,0x30,0xFF,0xFF
};
/*"照",1*/
/* (16 X 16 , 宋体 )*/

unsigned char bmp_hong[32] = {
    0xDF,0xCF,0x53,0x9C,0xDF,0xE7,0xFF,0xFB,0xFB,0xFB,0x03,0xFB,0xFB,0xFB,0xFF,0xFF,
    0xDD,0x98,0xDD,0xED,0xED,0xED,0xBF,0xBF,0xBF,0xBF,0x80,0xBF,0xBF,0xBF,0xBF,0xFF
};
/*"红",2*/
/* (16 X 16 , 宋体 )*/

unsigned char bmp_wai[32] = {
    0xFF,0x3F,0xCF,0xE0,0xEF,0xEF,0x0F,0xFF,0xFF,0x00,0xDF,0xBF,0x7F,0xFF,0xFF,0xFF,
    0x7E,0xBF,0xDE,0xED,0xF3,0xFC,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFC,0xFF,0xFF
};
/*"外",3*/
/* (16 X 16 , 宋体 )*/

//温度图片 40*40
unsigned char bmp_wendu[200] = {
    0x00,0x08,0x10,0xA0,0x40,0x20,0x3C,0x20,0x40,0xA0,0x10,0x08,0x00,0x00,0x00,0x00,
    0xF8,0x04,0xE2,0xF2,0xF2,0xE2,0x04,0xF8,0x00,0xA0,0xA0,0xA0,0x20,0x20,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x21,0x11,0x0B,0x04,0x08,0x78,0x08,
    0x04,0x0B,0x11,0x21,0x01,0x00,0x00,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,
    0x00,0xAA,0xAA,0xAA,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,
    0xBF,0xC0,0xFF,0xFF,0xFF,0xFF,0xC0,0xBF,0x20,0x4A,0x8A,0x0A,0x0A,0x02,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x1E,0x61,0x80,0x1F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,
    0x1F,0x80,0x61,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
    0x01,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

//湿度图片 40*40
unsigned char bmp_shidu[200] = {
    0x00,0x00,0x00,0x80,0xC0,0xF0,0xFC,0xF0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
    0xF8,0x04,0xE2,0xF2,0xF2,0xE2,0x04,0xF8,0x00,0xA0,0xA0,0xA0,0x20,0x20,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,0x3F,0x3F,0x3F,
    0x1F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,
    0x00,0xAA,0xAA,0xAA,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,
    0xBF,0xC0,0xFF,0xFF,0xFF,0xFF,0xC0,0xBF,0x20,0x4A,0x8A,0x0A,0x0A,0x02,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x1E,0x61,0x80,0x1F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,
    0x1F,0x80,0x61,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
    0x01,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

//光照图片 40*40
unsigned char bmp_sun[] = {
    /*
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x70,0xC0,0x80,0x00,0x00,0x00,
    0x00,0x00,0x00,0x7E,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0x70,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x30,0x60,0x60,0x60,
    0xC0,0x00,0x00,0x80,0xE3,0xF1,0xF8,0xFC,0xFC,0xFC,0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,
    0xF8,0xF8,0xF3,0xE1,0x80,0x00,0x40,0x40,0x60,0x60,0x60,0x30,0x20,0x00,0x00,0x00,
    0x00,0x00,0x00,0x80,0xC0,0xC0,0x40,0x60,0x60,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x1F,0x00,0x00,0x60,
    0x60,0x40,0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x80,0xE0,0x70,0x38,0x09,0x03,0x03,0x07,0x07,0x07,0xE7,0xE7,0x07,0x07,0x03,
    0x03,0x01,0x18,0x38,0x70,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    */
    
    0x00,0x00,0x00,0x00,0x00,0x0C,0x18,0x70,0x20,0x00,0x80,0x80,0x80,0xC0,0xCF,0xCF,
    0xC0,0x80,0x80,0x00,0x00,0x60,0x30,0x1C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x0C,0x18,0x00,0x00,0xF0,0xFC,
    0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xF0,
    0x00,0x08,0x08,0x0C,0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x18,0x08,0x0C,0x0C,0x00,0x00,0x07,0x1F,0x3F,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0x7F,0x7F,0x3F,0x1F,0x0F,0x03,0x00,0x00,0x0C,0x0C,0x1C,0x18,0x18,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x1C,0x0E,0x07,
    0x01,0x00,0x00,0x00,0x00,0x00,0x7C,0x7C,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x1E,
    0x38,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

//红外图片 40*40
unsigned char bmp_infrared[] = {
    /*
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0xC0,0xE0,
    0xE0,0xE0,0xF0,0xF0,0xF0,0xF0,0xE0,0xE0,0xE0,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF0,0xF8,0x78,0x7C,0x3C,0x1E,
    0x0F,0x0F,0x07,0x07,0x83,0x83,0xC1,0xE1,0xE1,0x60,0x70,0x70,0x70,0x70,0x60,0xE1,
    0xE1,0xC3,0x83,0x87,0x07,0x0F,0x0F,0x1E,0x3E,0x7C,0xF8,0xF0,0xE0,0xC0,0x00,0x00,
    0x00,0x01,0x01,0x00,0x00,0x00,0x30,0x38,0x38,0x1C,0x0E,0x07,0x83,0xC3,0x61,0x30,
    0x38,0x18,0x0C,0x0C,0x0C,0x0C,0x18,0x18,0x30,0x61,0xC3,0x87,0x0F,0x1E,0x3C,0x38,
    0x30,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x80,0xC0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xC0,
    0x80,0x00,0x00,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0F,0x0F,
    0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
    0x0C,0x0C,0x0C,0x0C,0x00,0x00,0x00,0x00,
    */
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0xE0,0xE0,0xE0,
    0xE0,0xE0,0xE0,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0x70,0x38,0x1C,0x0E,0x06,0x87,
    0xC3,0xE3,0x71,0x31,0x39,0x18,0x18,0x18,0x18,0x18,0x18,0x39,0x71,0x73,0xE3,0xC7,
    0x86,0x0C,0x1C,0x38,0x70,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x18,0x1C,0x0E,0x07,0x03,0x41,0x60,0x30,0x18,0x0C,0x0C,0x0C,0x0C,
    0x0C,0x0C,0x0C,0x0C,0x18,0x30,0x60,0x41,0x03,0x07,0x0E,0x1C,0x18,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x30,
    0x30,0x30,0x38,0x3C,0x3E,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3E,0x3C,0x38,0x30,0x30,
    0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

//灯亮图片 32*32
unsigned char bmp_light_on[] = {
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x38,0x70,0x00,0x80,0x80,0x80,0xCE,0xDF,
    0xC0,0x80,0x80,0x00,0x20,0x70,0x38,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x06,0x06,0x06,0x04,0x00,0xF8,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x70,0x00,0x04,0x06,0x02,0x02,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x03,0x03,0x03,0x01,0xC0,0xE0,0x73,0x07,0x1F,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0x0F,0x27,0x73,0xE0,0x80,0x01,0x03,0x03,0x03,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x12,0x32,0x32,
    0x32,0x12,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

//灯灭图片 32*32
unsigned char bmp_light_off[] = {
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xC0,0xC0,
    0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x1F,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0x0F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x12,0x32,0x32,
    0x32,0x12,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
/*"D:\华清远见\4-实训\2024-12-09四川农业大学\dengliang.bmp",0*/
/* (32 X 31 )*/

//风扇开图片 32*32
unsigned char bmp_fan_on[] = {
    0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFC,0xFC,0xFC,0xF8,
    0x00,0x14,0x94,0xC4,0xEC,0xE8,0xE8,0xE0,0xE0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,
    0x00,0x00,0xF8,0x06,0x60,0x17,0x4F,0x5F,0x3F,0x3F,0x7F,0x7F,0x7F,0xFF,0xFF,0x30,
    0x30,0xFE,0xFF,0x7F,0x3F,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x9C,0x00,0x00,
    0x00,0x00,0x08,0x7E,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFE,0xFF,0xFF,0x7F,0x0E,
    0x06,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,0xF3,0x00,0x18,0x0F,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x07,0x07,0x03,0x0B,0x09,0x1A,0x16,0x10,
    0x07,0x0F,0x1F,0x1F,0x1F,0x1F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,
};
/*"D:\华清远见\4-实训\2024-12-09四川农业大学\fan.bmp",0*/
    /* (32 X 31 )*/

//风扇关图片 32*32
unsigned char bmp_fan_off[] = {
    0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFC,0xFC,0xFC,0xF8,
    0x00,0x00,0x80,0xC0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x07,0x0F,0x1F,0x3F,0x3F,0x7F,0x7F,0x7F,0xFF,0xFF,0x30,
    0x30,0xFE,0xFF,0x7F,0x3F,0x3F,0x3F,0x7F,0x7F,0x7F,0xFF,0x7F,0x7F,0x1C,0x00,0x00,
    0x00,0x00,0x08,0x7E,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFE,0xFF,0xFF,0x7F,0x0E,
    0x06,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,0xF0,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x07,0x07,0x03,0x03,0x01,0x00,0x00,0x00,
    0x07,0x0F,0x1F,0x1F,0x1F,0x1F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,
};
/*"D:\华清远见\4-实训\2024-12-09四川农业大学\fan.bmp",0*/
    /* (32 X 31 )*/

//报警开图片 32*32

//报警关图片 32*32

unsigned char bmp_lux[] = {
    0x00,0xF0,0x00,0x00,0x00,0x80,0x00,0x00,0x80,0x00,0x80,0x00,0x00,0x00,0x80,0x00,
    0x00,0x3F,0x20,0x20,0x00,0x1F,0x20,0x20,0x1F,0x00,0x20,0x1B,0x0C,0x1B,0x20,0x00,
};

unsigned char bmp_um[] = {
    0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xC0,0x20,0x20,0xC0,0x20,0x20,0xC0,0x00,
    0x40,0x20,0x1F,0x08,0x08,0x0F,0x00,0x00,0x1F,0x00,0x00,0x1F,0x00,0x00,0x1F,0x00,
};
#endif
#if 1
void show_title(int type)
{
    SSD1306_DrawBMP(8, 0,8, 16, bmp_kongge); //kongge
    SSD1306_DrawBMP(16, 0,8, 16, bmp_kongge); //kongge
    SSD1306_DrawBMP(24, 0,8, 16, bmp_kongge); //kongge
    SSD1306_DrawBMP(32, 0,8, 16, bmp_kongge); //kongge
    SSD1306_DrawBMP(40, 0,8, 16, bmp_kongge); //kongge
    switch(type)
    {
        case WENDU:
            SSD1306_DrawBMP(48, 0, 16, 16, bmp_wen); 
            SSD1306_DrawBMP(64, 0, 16, 16, bmp_du);
            break;
        case SHIDU:
            SSD1306_DrawBMP(48, 0, 16, 16, bmp_shi); 
            SSD1306_DrawBMP(64, 0, 16, 16, bmp_du);
            break;
        case GUANGZHAO:
            SSD1306_DrawBMP(48, 0, 16, 16, bmp_guang); 
            SSD1306_DrawBMP(64, 0, 16, 16, bmp_zhao);
            break;
        case HONGWAI:
            SSD1306_DrawBMP(48, 0, 16, 16, bmp_hong); 
            SSD1306_DrawBMP(64, 0, 16, 16, bmp_wai);
            break;
        default:
            break;
    }

    SSD1306_DrawBMP(80, 0,8, 16, bmp_kongge); //kongge
    SSD1306_DrawBMP(88, 0,8, 16, bmp_kongge); //kongge
    SSD1306_DrawBMP(96, 0,8, 16, bmp_kongge); //kongge
    SSD1306_DrawBMP(104, 0,8, 16, bmp_kongge); //kongge
    SSD1306_DrawBMP(112, 0,8, 16, bmp_kongge); //kongge
}
#endif
#if 1

void show_content(float val, int type)
{
    // 放大100倍后，计算出十位数字
    int x = (val * 100) / 1000;
    SSD1306_DrawBMP(number_1.left, number_1.top, number_1.width, number_1.hight, bmp_16X32_number[x]); 

    // 放大100倍后，计算出个位数字
    x = ((int)(val * 100)) / 100 % 10;
    SSD1306_DrawBMP(number_2.left, number_2.top, number_2.width, number_2.hight, bmp_16X32_number[x]); 
    SSD1306_DrawBMP(dian_kongge.left, dian_kongge.top, dian_kongge.width, dian_kongge.hight, bmp_kongge2);  
    SSD1306_DrawBMP(dian.left, dian.top, dian.width, dian.hight, bmp_16X16_dian);              

    // 放大100倍后，计算出小数点位数字
    x = ((int)(val * 100)) / 10 % 10;
    SSD1306_DrawBMP(number_3.left, number_3.top, number_1.width, number_1.hight, bmp_16X32_number[x]);

    switch(type)
    {
        case WENDU:
            SSD1306_DrawBMP(danwei.left, danwei.top, danwei.width, danwei.hight, bmp_16X16_sheShiDu);      
            SSD1306_DrawBMP(image.left, image.top, image.width, image.hight, bmp_wendu);  
            break;
        case SHIDU:
            SSD1306_DrawBMP(danwei.left, danwei.top, danwei.width, danwei.hight, bmp_16X16_baifenhao);    
            SSD1306_DrawBMP(image.left, image.top, image.width, image.hight, bmp_shidu);  
            break;

        case GUANGZHAO:
            SSD1306_DrawBMP(danwei.left, danwei.top, danwei.width, danwei.hight, bmp_lux);    
            SSD1306_DrawBMP(image.left, image.top, image.width, image.hight, bmp_sun);   
            break;
        case HONGWAI:
            SSD1306_DrawBMP(danwei.left, danwei.top, danwei.width, danwei.hight, bmp_um);    
            SSD1306_DrawBMP(image.left, image.top, image.width, image.hight, bmp_infrared);
            break;
        default:
            break;
    }

}

#endif
#if 1
void show_temp_page(float val)
{
    //SSD1306_CLS();
    show_title(WENDU);
    show_content(val, WENDU);
}

void show_humi_page(float val)
{
    // 显示标题 中间居中显示
    //SSD1306_CLS();   
    show_title(SHIDU);
    show_content(val, SHIDU);
}

void show_light_page(int val)
{   
    //SSD1306_CLS();   
    show_title(GUANGZHAO);
    show_content(val, GUANGZHAO);
}

void show_infrared_page(int val)
{
    //SSD1306_CLS();   
    show_title(HONGWAI);
    show_content(val, HONGWAI);
}

void show_lamp_fan_page(void)
{
    SSD1306_CLS(); 
    // 灯 
    if(globals_dev_status.lamp_state.lamp_power == POWER_STATUS_ON){
        // 显示 灯开
        SSD1306_DrawBMP(png_left.left, png_left.top, 32, 32, bmp_light_on);   
        SSD1306_ShowStr(text_left.left, text_left.top, "ON ", 16);
    }
    else{
        // 显示 灯灭
        SSD1306_DrawBMP(png_left.left, png_left.top, 32, 32, bmp_light_off);   
        SSD1306_ShowStr(text_left.left, text_left.top, "OFF", 16);
    }

    if(globals_dev_status.beep_state.beep_power == POWER_STATUS_ON){  
        // 显示 报警开
        SSD1306_DrawBMP(png_middle.left, png_middle.top, 32, 32, bmp_32X32_BaoJing);   
        SSD1306_ShowStr(text_middle.left, text_middle.top, "ON ", 16);
    }
    else{
        // 显示 报警关
        SSD1306_DrawBMP(png_middle.left, png_middle.top, 32, 32, bmp_32X32_No_BaoJing);   
        SSD1306_ShowStr(text_middle.left, text_middle.top, "OFF", 16);
    }

    if(globals_dev_status.fan_state.fan_power == POWER_STATUS_ON){  
        // 显示 风扇开
        SSD1306_DrawBMP(png_right.left, png_right.top, 32, 32, bmp_fan_on);   
        SSD1306_ShowStr(text_right.left, text_right.top, "ON ", 16);
    }
    else{
        // 显示 风扇关
        SSD1306_DrawBMP(png_right.left, png_right.top, 32, 32, bmp_fan_off);   
        SSD1306_ShowStr(text_right.left, text_right.top, "OFF", 16);
    }
}

void show_oled(void)
{
    //SSD1306_CLS();
    uint8_t r = 0,g = 0,b = 0;
    uint8_t bmp_flag = 0;
    float temperature = 25.3, humidity = 16.7;
    float light = 30, infrared = 20;
    
    if(keyflag == 0)
    {
        show_temp_page(globals_dev_status.temperature);
    }else if(keyflag == 1)
    {
        show_humi_page(globals_dev_status.humidity);
    }else if(keyflag == 2)
    {
        show_light_page(globals_dev_status.light);
    }else if(keyflag == 3)
    {
        show_infrared_page(globals_dev_status.infrared);
    }
    else if(keyflag == 4)
    {
        show_lamp_fan_page();
    }else if(keyflag == 5)
    {
        SSD1306_CLS();
    }
    usleep(2000*1000);
}
#endif
/**
 * @brief 更新OLED的一行显示
 * @note 传入的数据长度不能超过16，超过会显示异常
 * @param {*}
 * @return {*}
 */
void oled_show(char *str, int line)
{
    SSD1306_ShowStr(OLED_TEXT16_COLUMN_0, line, str, TEXT_SIZE_16);
}

/**
 * @brief 更新OLED的显示
 * @note 取出全局变量结构体的内容，显示本地IP，客户端数量，电压，距离，左右轮速
 * @param {*}
 * @return {*}
 */
void Oled_Update_Carstatus(void)
{

}
